// 把类创建逻辑 和 单例模式分开。

function Window(name) {
    this.name = name;

}
Window.prototype.getName = function () {
    console.log(this.name)
}
//处理单例模式
let CreatSingle = (function () {
    let instance;
    return function (name) {
        if (!instance) {
            instance = !new Window(name);
        }
        return instance;
    }
}
)()

// 用法
let w1 = new CreatSingle("js");
let w2 = new CreatSingle("html");


console.log(w1 === w2)
